#include <iostream>
#include <cstdint>
#include <cstring>
#include <algorithm>
#include <cmath>

// PAT A 1002

static const float FLOAT_EPS = 1e-5f;

static float a[1001], b[1001], c[1001];

int readPoly(float *arr) {
    int n;
    std::cin >> n;
    int maxExp = 0;
    for (int i = 0; i < n; i++) {
        int exp;
        float coeff;
        std::cin >> exp >> coeff;
        arr[exp] = coeff;
        maxExp = std::max(maxExp, exp);
    }
    return maxExp;
}

inline bool isValid(float v) {
    return v > FLOAT_EPS || v < -FLOAT_EPS;
}

int main() {
    memset(a, 0, sizeof(a));
    memset(b, 0, sizeof(b));
    memset(c, 0, sizeof(c));
    int aExp = readPoly(a);
    int bExp = readPoly(b);
    int maxExp = std::max(aExp, bExp);
    int valid = 0;
    for (int i = 0; i <= maxExp; i++) {
        c[i] = a[i] + b[i];
        if (isValid(c[i]))
            valid++;
    }
    printf("%d", valid);
    for (int i = maxExp; i >= 0; i--) {
        if (!isValid(c[i]))
            continue;
        printf(" %d %.1f", i, c[i]);
    }
    printf("\n");
}